import { _decorator, Component, Node, v3, Vec3 } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('followCtl')
export class followCtl extends Component {
    @property(Node)
    followNode: Node = null;
    start() {

    }

    _tmpPos: Vec3 = v3()
    update(deltaTime: number) {
        this.node.getPosition(this._tmpPos)
        // let dis = this._tmpPos.subtract(this.followNode.getPosition()).lengthSqr()
        // if (dis <= 100) {
        // return
        // }

        if (this.followNode) {
            // Vec3.lerp(this.node.position, this.node.position, this.followNode.position, 0.1)
            this.node.position = this.followNode.position
        }
    }
}


